package graphic.mycomponents;

import java.awt.Cursor;
import java.awt.event.ActionListener;
import java.net.URL;

import javax.swing.ImageIcon;
import javax.swing.JButton;

import utility.GraphicUtilsFactory;
import core.ServerParameters;

public abstract class OpenDialogButton extends JButton implements ActionListener {
	
	public Object data;
	
	public OpenDialogButton(String imageName, String toolTipText, String altText, Object data)
	{
		super();
		
		this.data = data;

		URL imageURL = GraphicUtilsFactory.class.getClassLoader().getResource(ServerParameters.BUTTON_IMAGE_PATH + imageName);

		ImageIcon icon = new ImageIcon(imageURL, altText);
		
		super.setToolTipText(toolTipText);
		super.setIcon(icon);
		super.setAlignmentX(CENTER_ALIGNMENT);
		super.setBorder(null);
		super.setOpaque(false);
		super.setCursor(new Cursor(Cursor.HAND_CURSOR));
		//super.setPreferredSize(new Dimension(icon.getIconWidth(), icon.getIconHeight()));
		super.addActionListener(this);
	}	
}